<?php
/**
 * Created by wjssk-blog
 * user: alan.yue
 * Date：2021-02-10
 * Time: 22:04
 */

namespace app\common\controller;

use think\Controller;
use think\facade\Env;

class Error extends Controller
{
    public function index()
    {
        $url = request()->url();
        $url = str_replace(strstr($url, '?'), '', $url);
        $url = explode('/', $url)[1];

        //获取工具信息
        $tool_info = model('admin/Toolslist')->where('url', $url)->find();
        $this->assign('tool_info', $tool_info);
        if (is_dir(Env::get('root_path') . DIRECTORY_SEPARATOR . 'tools' . DIRECTORY_SEPARATOR . $url)) {
            $this->view->engine->layout(Env::get('root_path') . 'tools/public/layout.php');
            return $this->fetch(Env::get('root_path') . 'tools/' . $url . '/index.php');
        } else {
            $this->view->engine->layout(Env::get('root_path') . 'tools/public/layout.php');
            return $this->fetch(Env::get('root_path') . 'tools/public/error.php');
        }
    }
}